package com.goldze.mvvmhabit.ui.expandswipe;

import androidx.databinding.ObservableArrayList;
import androidx.databinding.ObservableField;
import androidx.databinding.ObservableList;

import com.goldze.mvvmhabit.widght.expandswipe.ExpandSwipeViewModel;

public class ExpandSwipeParentViewModel implements ExpandSwipeViewModel {

    public ObservableList<ExpandSwipeViewModel> mDatas = new ObservableArrayList<>();
    private int index;
    private boolean isPinned;
    private int swipetype;
    public ObservableField<String> text = new ObservableField<>("");
    public ExpandSwipeParentViewModel(int index,String string) {
        this.index = index;
        this.text.set(string);
    }

    public void initData(){
        mDatas.clear();
        for (int i = 0; i < 5; i++) {
//            KLog.e("sss  "+i);
            ExpandSwipeChildViewModel childViewModel = new ExpandSwipeChildViewModel(this,i,"第"+(i+1)+"条数据");
            childViewModel.ininData();
            mDatas.add(childViewModel);
        }
    }
    @Override
    public ExpandSwipeViewModel getChild(int position) {
        return mDatas.get(position);
    }

    @Override
    public ObservableList<ExpandSwipeViewModel> getItems() {
        return mDatas;
    }

    @Override
    public int getChildCount() {
        return mDatas.size();
    }

    @Override
    public long getId() {
        return index;
    }

    @Override
    public long getChildId(int position) {
        return mDatas.get(position).getId();
    }

    @Override
    public void setPinned(boolean pinned) {
        this.isPinned = pinned;
    }

    @Override
    public boolean isPinned() {
        return isPinned;
    }

    @Override
    public void setSwipeType(int type) {
        this.swipetype = type;
    }

    @Override
    public int getSwipeType() {
        return swipetype;
    }
}
